package com.shangxian.giveithome.controller;

import com.shangxian.giveithome.annoaction.CheckLoginStatus;
import com.shangxian.giveithome.entity.report.InputBlackList.UserConditionParam;
import com.shangxian.giveithome.entity.report.InputBlackList.Number;
import com.shangxian.giveithome.entity.report.InputBlackList.ReportList;
import com.shangxian.giveithome.result.Result;
import com.shangxian.giveithome.service.NewReportService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
import org.springframework.web.bind.annotation.*;

/**
 * @author Administrator
 * 新版举报接口
 */
@Api(tags = "新举报中心模块")
@RestController
@RequestMapping("/newReport")
public class NewReportController {

    @Autowired
    private NewReportService newReportService;

    @GetMapping("findBlackListByUserOrPhone")
    @ApiOperation(value = "根据用户名或者手机号查询黑名单信息")
    @CheckLoginStatus
    public Result findBlackListByUserOrPhone(@RequestParam("value") String value, @PageableDefault(page = 0,size = 10)Pageable pageable){
        return Result.success(newReportService.findBlackListByUserOrPhone(value,pageable));
    }

    @PostMapping("submitReport")
    @ApiOperation(value = "提交举报")
    @CheckLoginStatus
    public Result submitReport(@RequestBody ReportList reportList){
        newReportService.submitReport(reportList);
        return  Result.success();
    }

    @PostMapping("backBlockedUser")
    @ApiOperation(value = "后台根据手机号封禁用户")
    public Result blockedUser(@RequestBody Number numberParam){
        newReportService.blockedUser(numberParam);
        return Result.success();
    }

    @PostMapping("backAuditNormal")
    @ApiOperation(value = "后台审核正常")
    public Result auditNormal(@RequestBody Number numberParam) {
        newReportService.auditNormal(numberParam);
        return Result.success();
    }

    @PostMapping("backUnblockUser")
    @ApiOperation(value = "后台解禁封禁用户")
    public Result unblockUser(@RequestBody Number param){
        newReportService.unblockUser(param);
        return Result.success();
    }

    @GetMapping("backfindAllAuditUser")
    @ApiOperation(value = "查询所有被封禁的用户")
    public Result findAllAuditUser(@PageableDefault(page = 0,size = 10) Pageable pageable){
        return Result.success(newReportService.findAllBlockedUser(pageable));
    }

    @GetMapping("backfindBlackListHistory")
    @ApiOperation(value = "后台查询黑名单记录(默认全部查询)")
    public Result findBlackListHistory(@RequestParam(value = "state",required = false) Long state, @PageableDefault(page = 0,size = 10) Pageable pageable){
        return Result.success(newReportService.findBlackListHistory(state, pageable));
    }

    @GetMapping("backfindAllUser")
    @ApiOperation(value = "后台查询用户信息（多条件查询）")
    public Result findAllUser( UserConditionParam condition, @PageableDefault(page = 0,size = 10) Pageable pageable){
        return Result.success(newReportService.findAllUser(condition,pageable));
    }
}
